#!/bin/bash

set -x

UWSGI_PID_FILE=/tmp/uwsgi-api-compat.pid
if [ -e "$UWSGI_PID_FILE" ]; then
  UWSGI_PID=`cat "$UWSGI_PID_FILE"`
  echo "Previous uwsgi master process pid file detected, killing process $UWSGI_PID..."
  kill -TERM "$UWSGI_PID"
  sleep 4
fi

# wait for syslog to start up
sleep 1

exec run-consul-template -config /etc/consul-template-api-compat.conf
